package com.example.photo.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;

/**
 * 时间字符串解析
 * @author Lwh
 * @time 2023/04/27 20:19
 */
public class DataUtils {
    public static LocalDateTime get(String str) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date date = format.parse(str);
            Instant instant = date.toInstant();
            return instant.atZone(ZoneOffset.of("+8")).toLocalDateTime();
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}